package com.cslg.yougou.front.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cslg.yougou.front.entity.YougouGoods;
import com.cslg.yougou.front.mapper.YougouGoodsMapper;
import com.cslg.yougou.front.pojo.GoodsProfile;
import com.cslg.yougou.front.pojo.Result;
import com.cslg.yougou.front.service.YougouGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyw
 * @since 2020-11-06
 */
@Service
public class YougouGoodsServiceImpl extends ServiceImpl<YougouGoodsMapper, YougouGoods> implements YougouGoodsService {

    @Override
    public Result getGoods(Integer goodsTypeId, Integer pageSize, Integer currentPage) {
        Page<GoodsProfile> userPage = new Page<>(currentPage, pageSize);
        IPage<GoodsProfile> goodsProfileIPage = null;
        try {
             goodsProfileIPage = this.baseMapper.selectGoodsProfile(userPage, goodsTypeId);
        }catch (Exception e){
            return Result.errorMsg("数据库出现了异常，请联系管理员!");
        }
        return Result.ok(goodsProfileIPage);
    }
    @Override
    public Result getGoodsDetail(Integer goodsId) {
        YougouGoods yougouGoods = null;
        try {
            yougouGoods = this.baseMapper.selectById(goodsId);
        }catch (Exception e){
            return Result.errorMsg("数据库出现了异常，请联系管理员!");
        }
        return Result.ok(yougouGoods);


    }

    @Override
    public Result getUserLikeGoods(Integer pageSize, Integer currentPage) {
        Page<GoodsProfile> page = new Page<>(currentPage,pageSize);
        return Result.ok();
    }
}
